package com.miaocat19.service;

import com.miaocat19.error.BusinessException;
import com.miaocat19.service.model.ItemModel;

import java.util.List;

/**
 * @program: Javamiaosha
 * @description:
 * @author: miaocat19
 * @create: 2021-12-10 15:18
 **/
public interface ItemService {

    ItemModel createItem(ItemModel itemModel) throws BusinessException;

    /**
     * 根据商品的id获取详情
     */
    ItemModel getItemById(Integer id);

    /*把商品进行缓存  然后从redis中获取获取想要的数据*/
    ItemModel getItemByIdInCache(Integer id);

    /**
     * 商品展示list
     */
    List<ItemModel> listItem();

    /*落减库存*/
    boolean decreaseStock(Integer itemId, Integer amount);

    boolean increaseStock(Integer itemId, Integer amount);

    /*异步库存*/
    boolean asyncDecreaseStock(Integer itemId, Integer amount);

    /*商品的销量增加*/
    void increaseSale(Integer itemId, Integer amount);

    /*初始化库存的流水*/
    String initStockLog(Integer itemId, Integer amount);
}
